<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/XGameAdmin_template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>XGame</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->

<!-- InstanceEndEditable -->
<link type="text/css" rel="stylesheet" href="CSS/adminCSS.css" />
</head>
<?php
include('lock.php');

if($_SERVER["REQUEST_METHOD"] == "POST")
{

	if(!empty($_POST['editID'])){
	$_SESSION['editID'] = addslashes($_POST['editID']);
	}
	$id = $_SESSION['editID'];
	
	if(!empty($_POST['name']) || !empty($_POST['price']))
	{
		$name = addslashes($_POST['name']);
		$price = addslashes($_POST['price']);
		$url = addslashes($_POST['url']);
		$desc = addslashes($_POST['desc']);
		$long_desc = addslashes($_POST['long_desc']);
		
		if(!empty($_FILES['photo']['tmp_name']))
		{
			$photo = addslashes(file_get_contents($_FILES['photo']['tmp_name']));
			$photo_size = getimagesize($_FILES['photo']['tmp_name']);			
		}
		
		if($photo_size==FALSE)
		{
			$sql1="UPDATE demo SET demo_name='$name', demo_price='$price', demo_url='$url', demo_desc='$desc', demo_long_desc='$long_desc' WHERE demo_ID='$id'";
			mysql_query($sql1);
			unset($_SESSION['editID']);
			header('Location: AdminGames.php');	
		}
		else
		{
			$sql1="UPDATE demo SET demo_name='$name', demo_picture='$photo', demo_price='$price', demo_url='$url', demo_desc='$desc', demo_long_desc='$long_desc' WHERE demo_ID='$id'";
			mysql_query($sql1);
			unset($_SESSION['editID']);
			header('Location: AdminGames.php');
		}
	}

	$sql = "SELECT * FROM demo Where demo_ID = '$id'";
	$result=mysql_query($sql);
	$row=mysql_fetch_array($result);
}


?>
<body>
<div id="container">

<div id="wrapper">

<div id="banner">
<ul class="topLink">
<li> Welcome, Admin </li>
<li> <a href="Logout.php"> Logout </a> </li>
</ul>

<img src="Assets/XGame.png" alt="XGame" />
</div>

<div id="menu">

<ul class="nav">
<li> <a href="AdminMember.php"> Member </a> </li>
<li> <a href="AdminNews.php"> News </a> </li>
<li> <a href="AdminGames.php"> Games </a> </li>
<li> <a href="AdminStock.php"> Stock </a> </li>
<li> <a href="AdminOrder.php"> Order </a> </li>
<li> <a href="AdminHistory.php"> History </a> </li>
</ul>

</div>

<div id="main">
<!-- InstanceBeginEditable name="Main" -->
<form id="registerUpdate" name="registerUpdate" method="POST" enctype="multipart/form-data">
<h3> Product Particular </h3>

<label>Product Name</label>
<input type="text" name="name" value="<?php echo $row["demo_name"]; ?>"/>

<label>Product Picture</label>
<input type="file" name="photo" />

<label>Description</label>
<input type="text" name="desc" value="<?php echo $row["demo_desc"]; ?>"/>

<label>Long Description</label>
<input type="text" name="long_desc" value="<?php echo $row["demo_long_desc"]; ?>"/>

<label>URL</label>
<input type="text" name="url" value="<?php echo $row["demo_URL"]; ?>"/>

<label>Unit Price</label>
<input type="text" name="price" value="<?php echo $row["demo_price"]; ?>"/>

<button type="submit">Update</button>

</form>
<!-- InstanceEndEditable -->
</div>

<div id="footer">
<p align="center"> &copy; &nbsp; 2012 XGame </p>
</div>

</div>

</div>

</body>
<!-- InstanceEnd --></html>
